cmake_minimum_required(VERSION 3.19)
project(chatclient LANGUAGES CXX)

find_package(Qt6 6.5 REQUIRED COMPONENTS Core Widgets)
find_package(Qt6 REQUIRED COMPONENTS Widgets)
find_package(Qt6 REQUIRED COMPONENTS Widgets)
find_package(Qt6 REQUIRED COMPONENTS Widgets)
find_package(Qt6 REQUIRED COMPONENTS Widgets)
find_package(Qt6 REQUIRED COMPONENTS Widgets)

qt_standard_project_setup()

qt_add_executable(chatclient
    WIN32 MACOSX_BUNDLE
    main.cpp
    mainwidget.cpp
    mainwidget.h
    mainwidget.ui
    model/data.h
    resource.qrc
    sessionfriendarea.h sessionfriendarea.cpp
    debug.h
    messageshowarea.h messageshowarea.cpp
    messageeditarea.h messageeditarea.cpp
    messageeditarea.h messageeditarea.cpp

)

qt_add_resources(
    chatclient
    PREFIX "/"
    FILES
    resource/image

)

target_link_libraries(chatclient
    PRIVATE
        Qt::Core
        Qt::Widgets
)
target_link_libraries(chatclient PRIVATE Qt6::Widgets)
target_link_libraries(chatclient PRIVATE Qt6::Widgets)
target_link_libraries(chatclient PRIVATE Qt6::Widgets)
target_link_libraries(chatclient PRIVATE Qt6::Widgets)
target_link_libraries(chatclient PRIVATE Qt6::Widgets)

include(GNUInstallDirs)

install(TARGETS chatclient
    BUNDLE  DESTINATION .
    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
)

qt_generate_deploy_app_script(
    TARGET chatclient
    OUTPUT_SCRIPT deploy_script
    NO_UNSUPPORTED_PLATFORM_ERROR
)
install(SCRIPT ${deploy_script})
